fix(geocoding): Navigate button silently fails for search results and drag-moved pins (#173)#174
Conversation
The "Navigate" button on the geocode-bar tracked its destination via a pinLayer 'layeradd' listener. That fires only when a new layer is added, which misses two flows: - Search "Go to location" calls pinLayer.clearLayers() and never adds a new pin, so currentPinLatLng stays null (silent fail) or stale (worse — navigates to the previous long-press pin). - Pin drag moves the same marker without re-adding, so the listener doesn't fire and Navigate goes to the original drop location, not the new dragged one. showGeocodeBar() is the single setter all three flows (search, long-press, drag) already converge on, so threading the L.LatLng through it captures the current destination reliably. Removed the 'layeradd' listener; replaced the silent-return guard with a toast so any future regression surfaces visibly. Closes #173 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Code ReviewOverviewThis PR fixes a genuine bug: the Net: -19/+13 lines, simpler invariant, better error visibility. Approve-ready with minor notes. Strengths
Issues / Suggestions1. Pin-drag path — verify The diff updates the two explicit 2. _showGeocodeBar?.(label, copyText, L.latLng(lat, lng));
3. No automated test coverage for the fixed flows The CLAUDE.md notes tests are pure-function only (no DOM/Leaflet integration), so this is expected and acceptable. The manual test plan in the PR description covers all three fixed flows plus the new null-guard toast. No change needed, just flagging it as an acknowledged gap. 4. Minor: comment in // "Navigate" button on the geocode-bar — start guidance to the destination
// associated with the currently-shown bar. showGeocodeBar() is the single
// setter so search-results, long-press, and pin-drag all stay in sync.The second and third lines are valuable context (they explain the why of the design). The comment is worth keeping as-is. Summary
The one thing worth confirming before merge is that the drag |
|
Confirming the drag path: |
Summary
pinLayer.on('layeradd')listener — fires only when a new layer is added to the group.pinLayer.clearLayers()and never adds a new pin →currentPinLatLngstaysnull(silent fail) or stale (worse — navigates to a previous long-press pin).Fix
Thread the destination
L.LatLngthroughshowGeocodeBar(label, copyText, latlng). That function is the single setter all three flows (search, long-press, drag) already converge on, so capturing the destination there is reliable. Removed the unreliablelayeraddlistener.Also replaced the silent-return guard with a
"No destination set"toast so any future regression surfaces visibly instead of vanishing.Closes #173.
Test plan
npm run type-checkcleannpm run lintcleannpm testclean (633 tests)🤖 Generated with Claude Code